//
//  Config.h
//  UserUse
//
//  Created by angra on 16/9/17.
//  Copyright © 2016年 CJPC. All rights reserved.
//

#ifndef Config_h
#define Config_h

/*
    用来存放全局的宏定义
 */
//打包地址 http://test.haivin.com:8080/cjpc/
#define kUrl(path)  [NSString stringWithFormat:@"http://www.usherpower.com:8080/CJPC/%@",path]

//获取cookie_token
#define cookie_token [kUserDefaults objectForKey:@"cookie_token"]?[kUserDefaults objectForKey:@"cookie_token"]:@""

//请求成功的时候
#define isSuccessRequest [responseObject[@"resultCode"] isEqualToString:@"200"]
//请求失败的时候
#define isFailureRequest [responseObject[@"resultCode"] isEqualToString:@"500"]

#define kIsAutologin  @"IsAutologin"                                                         /// 是否自动登录
#define kLastUsername @"LastUsername"                                                        /// 最后登录的用户名
#define kLastPassword @"LastPassword"                                                        /// 最后登录的密码
#define kLastToken    @"LastToken"                                                           /// 用户令牌 OA
#define kLastUserId   @"LastUserId"                                                          /// 用户id  OA
#define kLastShouShi  @"LastShouShi"                                                         /// 是否设置手势密码
#define kLastSS       @"LastSS"                                                              /// 是否启用手势密码
#define kLastOrgCode  @"OrgCode"                                                             ///组织机构代码
#define kLastUserLevel @"UserLevel"                                                          /// 用户类型
#define KCurrentStation @"CurrenStation"                                                     ///当前位置
#define KPayCancleTime     @"payCancleTime"                              ///支付取消时间
#define KLastPayID     @"LastPayID"                              ///最后一次支付ID
#define kUserDefaults       [NSUserDefaults standardUserDefaults]
#define kAppDelegate        (AppDelegate *)[[UIApplication sharedApplication] delegate]
#define kBundleLoadNibName(name) [[[NSBundle mainBundle] loadNibNamed:name owner:nil options:nil] lastObject]
#define is_IOS_7 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
/// 常用宏定义
#define kNotificationCenter [NSNotificationCenter defaultCenter]
#define kApplication        [UIApplication sharedApplication]
#define kAppDelegate        (AppDelegate *)[[UIApplication sharedApplication] delegate]
#define kFileManager        [NSFileManager defaultManager]
#define kBundle             [NSBundle mainBundle]
#define kDevice             [UIDevice currentDevice]
#define kWindow             [[UIApplication sharedApplication] keyWindow]
#define kBundleVersion      [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]
#define kDocumentPath       [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]
#define kBundleLoadNibName(name) [[[NSBundle mainBundle] loadNibNamed:name owner:nil options:nil] lastObject]


#define iPhone4 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)

#define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)

#define iPhone6 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen] currentMode].size) : NO)

#define iPhone6p ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) : NO)||([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2001), [[UIScreen mainScreen] currentMode].size) : NO)

#define iOS6 [[[UIDevice currentDevice]systemVersion] floatValue] < 7.0

#define iOS7 [[[UIDevice currentDevice]systemVersion] floatValue] >= 7.0

#define iOS8 [[[UIDevice currentDevice]systemVersion] floatValue] >= 8.0


#define kScreenFrame  [[UIScreen mainScreen] bounds]

#define kScreenFrameH CGRectGetHeight(kScreenFrame)

#define kScreenFrameW CGRectGetWidth(kScreenFrame)

#define kTabBarHeight 49

#define kNavigationBarHeight 64

#define kDeviceVersion [[UIDevice currentDevice] systemVersion]

#define kDeviceName  [[UIDevice currentDevice] systemName]

#define kDeviceModel [[UIDevice currentDevice] model]

#define kRGBColor(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1]
#define kScaleNum(num)    kScreenFrameW / 320.0f * (num)
#define kScaleNum6(num)    kScreenFrameW / 375.0f * (num)
#define kColoeString(color) [UIColor colorWithHexString:color]

/// 颜色
#define kBlackColor     [UIColor blackColor]      // 0.0 white
#define kDarkGrayColor  [UIColor darkGrayColor]   // 0.333 white
#define kLightGrayColor [UIColor lightGrayColor]  // 0.667 white
#define kWhiteColor     [UIColor whiteColor]      // 1.0 white
#define kGrayColor      [UIColor grayColor]       // 0.5 white
#define kRedColor       [UIColor redColor]        // 1.0, 0.0, 0.0 RGB
#define kGreenColor     [UIColor greenColor]      // 0.0, 1.0, 0.0 RGB
#define kBlueColor      [UIColor blueColor]       // 0.0, 0.0, 1.0 RGB
#define hCyanColor      [UIColor cyanColor]       // 0.0, 1.0, 1.0 RGB
#define hYellowColor    [UIColor yellowColor]     // 1.0, 1.0, 0.0 RGB
#define hMagentaColor   [UIColor magentaColor]    // 1.0, 0.0, 1.0 RGB
#define kOrangeColor    [UIColor orangeColor]     // 1.0, 0.5, 0.0 RGB
#define kPurpleColor    [UIColor purpleColor]     // 0.5, 0.0, 0.5 RGB
#define hBrownColor     [UIColor brownColor]      // 0.6, 0.4, 0.2 RGB
#define kClearColor     [UIColor clearColor]      // 0.0 white, 0.0 alpha
#define RGBColor0(_f)   [UIColor colorWithRed:((float)((_f & 0xFF0000) >> 16))/255.0 green:((float)((_f & 0xFF00)>> 8))/255.0 blue:((float) (_f & 0xFF))/255.0 alpha:1.0f]
#define RGBColor1(_r, _g, _b)     [UIColor colorWithRed:(_r)/255.0 green:(_g)/255.0 blue:(_b)/255.0 alpha:1.0f]
#define RGBColor2(_r, _g, _b, _a) [UIColor colorWithRed:(_r)/255.0 green:(_g)/255.0 blue:(_b)/255.0 alpha:_a]

/// 常用
#define ImageNamed(_name)     [UIImage imageNamed:_name]
#define URLWithString(str)    [NSURL URLWithString:str]
#define FontSize(_size)       [UIFont systemFontOfSize:_size]
#define HeiTiFont(_size)      [UIFont fontWithName:@"HelveticaNeue" size:_size]
#define CellLineColor         RGBColor0(0xaaaaaa)

#define StringWithInt(num)             [NSString stringWithFormat:@"%d", (num)]
#define NumberWithInt(num)             [NSNumber numberWithInt: (num)]

#define AlignmentLeft   NSTextAlignmentLeft
#define AlignmentCenter NSTextAlignmentCenter
#define AlignmentRight  NSTextAlignmentRight

//提示
#define showAlert(title,mesg)  [[[UIAlertView alloc]initWithTitle:title message:mesg delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil]show]
//#define AlertShow(_alert,_arReportType)   _alert = nil;_alert = [[UIAlertView alloc]initWithTitle:nil message:nil delegate:self cancelButtonTitle:@"取消" otherButtonTitles:_arReportType[0], _arReportType[1], _arReportType[2], _arReportType[3], _arReportType[4],_arReportType[5],_arReportType[6],nil];[_alert show];

#ifdef DEBUG
#define NSLog(...) NSLog(__VA_ARGS__)
#define debugMethod() NSLog(@"%s", __func__)
#else
#define NSLog(...)
#define debugMethod()
#endif


//#define iPhone4 (kHeight == 480)
//#define iPhone5 (kHeight == 568)
//#define iPhone6 (kHeight == 667)
//#define iPhone6p (kHeight == 736)
//#define multipe (iPhone5 ?320.f / kScreenFrameW * 2  : iPhone6 ? 320.f/ kScreenFrameW * 2 :  320.f/kScreenFrameW * 1.5)
//#define multipe (320.f/kScreenFrameW * 2)

//单例模式
#define SYNTHESIZE_SINGLETON_FOR_HEADER(className) \
\
+ (className *)shared##className;

//单例化一个类
#define SYNTHESIZE_SINGLETON_FOR_CLASS(classname) \
\
static classname *shared##classname = nil; \
\
+ (classname *)shared##classname \
{ \
@synchronized(self) \
{ \
if (shared##classname == nil) \
{ \
shared##classname = [[self alloc] init]; \
} \
} \
\
return shared##classname; \
} \
\
+ (id)allocWithZone:(NSZone *)zone \
{ \
@synchronized(self) \
{ \
if (shared##classname == nil) \
{ \
shared##classname = [super allocWithZone:zone]; \
return shared##classname; \
} \
} \
\
return nil; \
} \
\
- (id)copyWithZone:(NSZone *)zone \
{ \
return self; \
}

//#define multipe (iPhone5 ?320.f / kScreenFrameW * 2  : iPhone6 ? 320.f/ kScreenFrameW * 2 :  320.f/kScreenFrameW * 1.5)
#define multipe (320.f/kScreenFrameW * 2)
#define multipeH (568.f/kScreenFrameW * 2)
#define font(path) path
#endif /* Config_h */
